package io.chance.receiverlei.db;

import lrq.common.PropertiesUnit;
import lrq.data.DbExecuter;
import lrq.data.MysqlExecuter;

import java.beans.PropertyVetoException;

public class DbManager {
    static DbExecuter dbExecuter = null;

    /**
     * 获取数据库配置，初始化DbExecuter
     * gislin
     * 2015年10月24日
     */
    private static void Init() {
//		String oracleDbConnStr = PropertiesUnit.getValue("oracleDbConnStr");
//		System.out.println("数据库信息:"+oracleDbConnStr);
//		try {
//			dbExecuter = new OracleExecuter(oracleDbConnStr);
//		} catch (PropertyVetoException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
        String mysqlDbConnStr = PropertiesUnit.getValue("mysqlDbConnStr");
        System.out.println("数据库信息:" + mysqlDbConnStr);
        try {
            dbExecuter = new MysqlExecuter(mysqlDbConnStr);
        }
        catch (PropertyVetoException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public static DbExecuter getDbExecuter() {
        if (dbExecuter == null) {
            synchronized (DbManager.class) {
                if (dbExecuter == null) {
                    Init();
                }
            }
        }
        return dbExecuter;
    }
}